package com.wanxi.controller.test;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@CrossOrigin
@RequestMapping("back")
@Controller
public class AnnotationController {

    @GetMapping(path="anno")
    @ResponseBody
    public Map<String,String> hello() throws JsonProcessingException {

        ObjectMapper objectMapper = new ObjectMapper();

        System.out.println("进入注解跨域请求方法");

//        return objectMapper.writeValueAsString("success");   //构造返回值
        Map<String,String> map = new HashMap<>();
        map.put("你好","世界");
//        return "success";   //构造返回值
        return map;
    }

}
